<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
  <include file="Public/breadcrumb"/> 
  <style type="text/css">
  	.table input{display: nones;}
	#biaozhu{cursor: pointer;}
  </style>
   
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading"> 
          <h3 class="panel-title"><i class="fa fa-list"></i>线上支付余额记录</h3>
        </div>
        <div class="panel-body">
		<div class="navbar navbar-default">
                <form id="search-form2" class="navbar-form form-inline"  method="get" action="{:U('deduct')}">
                <div class="form-group">

                  <div class="input-group">
                    <input type="text" class="form-control" id="master_order_sn" placeholder="支付合并订单号" value="{$Think.request.master_order_sn}" name="master_order_sn" />
                  </div>

                  <div class="input-group">
                    <input type="text" class="form-control" id="company" placeholder="客户名称" value="{$Think.request.company}" name="company"/>
                  </div>
				<div class="form-group">
				                  <select name="status" id="status" class="form-control">
									<?php
										if(I('status')=='0'){
											echo '<option value="">全状态</option>
											<option value="0" selected="selected">未处理</option>
											<option value="1">已处理</option>';
									}elseif(I('status')=='1'){
										echo '<option value="">全状态</option>
										<option value="0">未处理</option>
										<option value="1" selected="selected">已处理</option>';
									}else{
										echo '<option value="" selected="selected">全状态</option>
										<option value="0">未处理</option>
										<option value="1">已处理</option>';
									}
									?>
				                  </select>
				                </div>
                   <div class="input-group margin" style="width: 250px;">                    
                   <!-- <div class="input-group-addon">
                        入库时间<i class="fa fa-calendar"></i>
                    </div> -->
                       <input type="text" id="start_time" value="{$timegap}" autocomplete="off" name="timegap" class="form-control pull-right">
                  </div>                  
                </div>
                <div class="form-group">
<!--					<button type="button" style="margin-left: 20px;" class="btn btn-primary pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>-->
					<button class="btn btn-primary" id="button-filter search-order" type="submit"><i class="fa fa-search"></i> 筛选</button>
                    <button type="button" data-toggle="tooltip" id="batch" class="btn btn-primary"><i class="fa fa-plus"></i>批量导入零钱</button>
                    <a href="{:U('Finance/add_money')}" style="margin:0px 10px" class="btn btn-info pull-right">添加余额</a>
                </div>


                    <div class="btn btn-default pull-right " style="color:red;font-size:25px;">合计：￥{$sum}</div>

                </form>
			
          </div>
                        
          <div id="ajax_return"> 
                 
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
								<th class="sorting text-center">ID</th>
                                <th class="sorting text-center">原合并订单号</th>
                                <th class="sorting text-center">客户名</th>
								<th class="sorting text-center">余额</th>
								<th class="sorting text-center">状态</th>
								<th class="sorting text-center">抵扣的合并单号</th>
                                <th class="sorting text-center">创建时间</th>
                            </tr>
                            </thead>
                            <tbody> 

                            <volist name="list" id="v">
                                <tr>
									<td class="text-center">{$v.id}</td>
									<td class="text-center">{$v.master_order_sn}</td>
                                    <td class="text-center">{$v.company}</td>
									<td class="text-center" style="color: red">￥{$v.money}</td>
                                    <if condition="$v.status eq 1">
										<td class="text-center" style="color:green;">已处理</td>
									<else />
										<td class="text-center" style="color:red;">未处理 <button class="btn btn-warning" onclick="deduct_edit({$v.id})">手动处理</button></td>
									</if>

                                    <td class="text-center">{$v.pay_sn}</td>
									<td class="text-center">{$v.create_time|date='Y-m-d H:i',###}</td>
                                </tr>
                            </volist>
                            </tbody>
                        </table>
                    </div>
                
                <div class="row">
                    <div class="col-sm-6 text-right">{$show}</div>
                </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
 <script>
	$(document).ready(function() {
        $('#start_time').daterangepicker({
            format: "YYYY-MM-DD HH:mm",
            singleDatePicker: false,
            showDropdowns: true,
            minDate: '2021-01-01 00:00',
            maxDate: '2030-01-01 00:00',
            startDate: '{:date("Y-m-d")} 00:00',
            showWeekNumbers: true,
            timePicker: true,
            timePickerIncrement: 1,
            timePicker12Hour: false,
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                '最近7天': [moment().subtract('days', 6), moment()],
                '最近30天': [moment().subtract('days', 29), moment()],
                '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
            },
            opens: 'left',
            buttonClasses: ['btn btn-default'],
            applyClass: 'btn-small btn-primary',
            cancelClass: 'btn-small',
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        });


    })
	
    //批量操作提交
    function deduct_edit(id) {

		layer.confirm('确定手动处理吗？操作后即可给客户转账', {
		  btn: ['确定','取消'] //按钮 
		}, function(){
			$.post('/index.php/Admin/Finance/deduct',{action:'edit',id:id},function(res){
                if(res.code){
                    layer.msg('操作成功', {icon:6},function(){
                        location.reload();
                    });
                }
			},'json');
			
		});
    }

    $("#batch").click(function(){
        var myrul='/index.php/admin/Finance/batch_deduct'
        layer.open({
            type: 2,
            shadeClose: true, //点击遮罩关闭
            title:'导入零钱',
            skin: 'layui-layer-rim', //加上边框
            area: ['920px', '620px'], //宽高
            content: myrul
        });
    });
</script>
</body>
</html>